package com.test;

public class CommonUtil {
    // 获取一个单链表
    public static ListNode getSingleLinkedList(int... ints) {
        ListNode dummyNode = new ListNode(-1);

        ListNode point = dummyNode;
        for (int one : ints) {
            ListNode listNode = new ListNode(one);
            point.next = listNode;
            point = point.next;
        }

        return dummyNode.next;
    }

    // 循环遍历单链表
    public static void printSingleLinkedList(ListNode listNode) {
        while (listNode != null) {
            System.out.println(listNode.val);
            listNode = listNode.next;
        }
    }


}
